<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>元素的显示与隐藏</title>
    <style>
      .content {
        width: 137px;
        height: 300px;
        background-color: pink;
        margin-top: 10px;
      }
    </style>
    <script src="lib/jQuery-v3.6.0.min.js"></script>
  </head>
  <body>
    <div class="btn">
      <button class="show">显示</button>
      <button class="hide">隐藏</button>
      <button class="toggle">切换</button>
    </div>
    <div class="content"></div>

    <script>
      $(function () {
        // 显示
        $('.show').click(function () {
          $('.content').show()
        })

        // 隐藏
        $('.hide').click(function () {
          $('.content').hide()
        })

        // 切换
        $('.toggle').click(function () {
          $('.content').toggle()
        })
        // 一般情况下，都是不加参数直接显示或隐藏就可以了
      })
    </script>
  </body>
</html>
